#include <string>

class Solution
{
public:
    static int lengthOfLongestSubstring(std::string s)
    {
        int left = 0;
        int right = 0;
        int len = 0;
        int hash[128] = {0};

        while(right < s.size())
        {
            hash[s[right]]++;
            while(hash[s[right]] > 1)
            {
                hash[s[left]]--;
                left++;
            }
            len = std::max(len, right-left+1);
            right++;
        }
        return len;
    }
};
